package com.bcu.calculus.service.serviceImpl;

import com.bcu.calculus.entity.Image;
import com.bcu.calculus.entity.Message;
import com.bcu.calculus.mapper.ImageMapper;
import com.bcu.calculus.service.ImageService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ImageServiceImpl implements ImageService {


    @Resource
    private ImageMapper imageMapper;

    @Override
    public Message<?> insert(Image image) {
        return imageMapper.insert(image) > 0 ? Message.success(null) : Message.fail(null);
    }

    @Override
    public Message<?> deleteByPrimaryKey(Integer imageId) {
        return imageMapper.deleteByPrimaryKey(imageId) > 0 ? Message.success(null) : Message.fail(null);
    }

    @Override
    public Message<?> updateByPrimaryKey(Image image) {
        return imageMapper.updateByPrimaryKey(image) > 0 ? Message.success(null) : Message.fail(null);
    }

    @Override
    public Message<Image> selectByPrimaryKey(Integer imageId) {
        return Message.success(null).add(imageMapper.selectByPrimaryKey(imageId));
    }

    @Override
    public Message<List<Image>> selectAllImage() {
        return Message.success(null).add(imageMapper.selectAllImage());
    }
}
